#pragma once
#include<qopenglwidget.h>
#include<qopenglfunctions_3_3_core.h>
#include <QOpenGLWidget>
#include <QOpenGLFunctions_3_3_Core>
#include <QOpenGLShaderProgram>
#include<QCoreApplication>
#include"DecodePipeLine.h"
#include<condition_variable>
#include<mutex>
class VideoWidget :
    public QOpenGLWidget,private QOpenGLFunctions_3_3_Core
{
public:
    VideoWidget(QWidget* parent) :QOpenGLWidget(parent) {}
    void RenderNV12Frame(char** data,int width,int height);
private:
    void paintGL() override;
    void resizeGL(int x,int y) override;
    void initializeGL() override;
private:
    unsigned int VBO_{};
    unsigned int VAO_{};
    unsigned int EBO_{};
    unsigned int vertex_shader_{};
    unsigned int fragment_shader_{};
    unsigned int shader_program_{};
    unsigned int y_texture_id_{};
    unsigned int u_texture_id_{};
    unsigned int v_texture_id_{};
    unsigned int u_sampler_location_{};
    unsigned int y_sampler_location_{};
    unsigned int v_sampler_location{};
    char** nv12_data_{nullptr};
    int width_{};
    int height_{};
};